home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / AWT / FontMetrics.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  1.9 KB  |  88 lines

  1. package java.awt;
  2.  
  3. public abstract class FontMetrics {
  4.    protected Font font;
  5.  
  6.    protected FontMetrics(Font var1) {
  7.       this.font = var1;
  8.    }
  9.  
  10.    public Font getFont() {
  11.       return this.font;
  12.    }
  13.  
  14.    public int getLeading() {
  15.       return 0;
  16.    }
  17.  
  18.    public int getAscent() {
  19.       return this.font.getSize();
  20.    }
  21.  
  22.    public int getDescent() {
  23.       return 0;
  24.    }
  25.  
  26.    public int getHeight() {
  27.       return this.getLeading() + this.getAscent() + this.getDescent();
  28.    }
  29.  
  30.    public int getMaxAscent() {
  31.       return this.getAscent();
  32.    }
  33.  
  34.    public int getMaxDescent() {
  35.       return this.getDescent();
  36.    }
  37.  
  38.    public int getMaxDecent() {
  39.       return this.getMaxDescent();
  40.    }
  41.  
  42.    public int getMaxAdvance() {
  43.       return -1;
  44.    }
  45.  
  46.    public int charWidth(int var1) {
  47.       return this.charWidth((char)var1);
  48.    }
  49.  
  50.    public int charWidth(char var1) {
  51.       if (var1 < 256) {
  52.          return this.getWidths()[var1];
  53.       } else {
  54.          char[] var2 = new char[]{var1};
  55.          return this.charsWidth(var2, 0, 1);
  56.       }
  57.    }
  58.  
  59.    public int stringWidth(String var1) {
  60.       int var2 = var1.count;
  61.       char[] var3 = new char[var2];
  62.       System.arraycopy(var1.value, var1.offset, var3, 0, var2);
  63.       return this.charsWidth(var3, 0, var2);
  64.    }
  65.  
  66.    public int charsWidth(char[] var1, int var2, int var3) {
  67.       return this.stringWidth(new String(var1, var2, var3));
  68.    }
  69.  
  70.    public int bytesWidth(byte[] var1, int var2, int var3) {
  71.       return this.stringWidth(new String(var1, 0, var2, var3));
  72.    }
  73.  
  74.    public int[] getWidths() {
  75.       int[] var1 = new int[256];
  76.  
  77.       for(char var2 = 0; var2 < 256; ++var2) {
  78.          var1[var2] = this.charWidth(var2);
  79.       }
  80.  
  81.       return var1;
  82.    }
  83.  
  84.    public String toString() {
  85.       return this.getClass().getName() + "[font=" + this.getFont() + "ascent=" + this.getAscent() + ", descent=" + this.getDescent() + ", height=" + this.getHeight() + "]";
  86.    }
  87. }
  88.